//
//  MoreSpecialTableViewCell.m
//  GiftItems
//
//  Created by lanou3g on 15/9/20.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "MoreSpecialTableViewCell.h"

@implementation MoreSpecialTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.SpecialImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, kWidth - 20, 150)];
        
        self.SpecialImageView.backgroundColor = [UIColor blackColor];
        [self.contentView addSubview:self.SpecialImageView];
       // self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = NO;
        
        self.SpecialImageView.layer.masksToBounds = YES;
        self.SpecialImageView.layer.cornerRadius = 5;
        
        
        
        self.titleLabel = [[UILabel alloc] init];
        //self.titleLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.05];
        
        
        self.subtitleLabel = [[UILabel alloc] init];
       // self.subtitleLabel.backgroundColor = [UIColor blackColor];
        [self.SpecialImageView addSubview:self.subtitleLabel];
        
        [self.SpecialImageView addSubview:self.titleLabel];
        
        
        
    }
    return self;
    
    
}

- (void)shareModel:(MainBoutiqueModel *)model {
    
    
    
CGFloat width = [self WidthText:model.title Height:40 size:25];
    
    self.titleLabel.frame = CGRectMake((self.SpecialImageView.frame.size.width - width) / 2, 40, width, 40);
    self.titleLabel.text = model.title;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.highlighted = YES;
    self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:25];
    
    CGFloat subWidth = [self WidthText:model.subtitle Height:40 size:14];
    self.subtitleLabel.frame = CGRectMake((self.SpecialImageView.frame.size.width - subWidth) / 2, 100, subWidth, 14);
    self.subtitleLabel.text = model.subtitle;
    self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
    self.subtitleLabel.numberOfLines = 0;
    self.subtitleLabel.highlighted = YES;
    self.subtitleLabel.textColor = [UIColor whiteColor];
    self.subtitleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];

    [self.SpecialImageView sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url] placeholderImage:[UIImage imageNamed:@"11"]];
    
    
}

//文字自适应宽度
- (CGFloat)WidthText:(NSString *)title Height:(CGFloat)height size:(CGFloat)size{
    CGRect font = [title boundingRectWithSize:CGSizeMake(1000, height) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:size] forKey:NSFontAttributeName] context:nil];
    
    return font.size.width;
}

- (void)awakeFromNib {
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
